from redis import StrictRedis


class Config(object):

    # 生成随机的secret_key
    SECRET_KEY = 'sgsXxRnn+N1aXwjii/9nfp+brrD30hSengl5t/Vqs6KxUI1Dua7Pj1LSONtNPCq9'

    # mysql配置
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/tuyu"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    SESSION_TYPE = "redis"
    # 对session-id进行加密
    SESSION_USE_SIGNER = True
    # 指定 session 保存的redis库
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)

    # SESSION_PERMANENT = True  # 如果设置为False,关闭浏览器session就会失效
    SESSION_PERMANENT = False
    # 设置session过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2
    # 保存到session中的值的前缀
    # SESSION_KEY_PREFIX = 'session:'


class DevelopmentConfig(Config):
    """开发环境下的配置"""
    DEBUG = True


config = {
    "development": DevelopmentConfig
}